package com.mz.ozy.mvp.presenter;


import android.app.Activity;


import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.mvp.model.AddressManagerModel;
import com.mz.ozy.mvp.view.AddressManagerContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class AddressManagerPresenter extends BasePresenterImpl<AddressManagerContract.View> implements AddressManagerContract.Presenter{

    private AddressManagerModel mModel;

    public AddressManagerPresenter(){
        mModel = new AddressManagerModel();
    }

    @Override
    public void saveAddres(Activity activity, String payPwd, String coinCode, String address, String remarkes) {
        mModel.saveAddress(activity,payPwd,coinCode,address,remarkes)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView){
                    @Override
                    public void onSuccesss(JSONObject jsonObject) {
                        mView.saveAddressuccess(jsonObject);
                    }
                });
    }


}
